package com.xuelang.pipeline.worker.client.deployment;

import com.xuelang.pipeline.worker.client.common.feign.DeploymentServiceFallbackImpl;
import com.xuelang.pipeline.worker.client.common.result.ApiResult;
import com.xuelang.pipeline.worker.client.deployment.dto.DeployQueryDTO;
import io.kubernetes.client.openapi.models.V1DeploymentList;
import io.kubernetes.client.openapi.models.V1Scale;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import jakarta.validation.Valid;
import java.util.List;

/**
 * @author liuyuan.ly
 * @since 2024/8/8 16:53
 */
@FeignClient(name = "deployment-service", url = "${feign.rpc.workerService}", fallback = DeploymentServiceFallbackImpl.class)
public interface IDeploymentService {

    /**
     * 查询  deployment
     *
     * @param queryDTO
     * @return
     */
    @PostMapping(value = "/get/deployment/list", produces = "application/json;charset=utf-8")
    ApiResult<V1DeploymentList> getDeploymentList(@RequestBody @Valid DeployQueryDTO queryDTO);

    /**
     * patch更新
     *
     * @param queryDTO
     * @return
     */
    @PostMapping(value = "/patch/deployment", produces = "application/json;charset=utf-8")
    ApiResult<V1Scale> patchDeployment(@RequestBody @Valid  DeployQueryDTO queryDTO);


    /**
     * 通过查询部署单Label，获取有效的deployment
     *
     * @param queryDTO
     * @return
     */
    @PostMapping(value = "/list/deployment/available", produces = "application/json;charset=utf-8")
    ApiResult<List<String>> listAvailableDeploymentName(@RequestBody @Valid  DeployQueryDTO queryDTO);

}
